package com.miku.blog.controller;

import com.miku.blog.annotation.SystemLog;
import com.miku.blog.domain.pojo.ResponseResult;
import com.miku.blog.domain.vo.TalkVo;
import com.miku.blog.service.TalkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author shkstart
 * @create ${}YEAR-06-13 21:22
 */
@Api(tags = "后台管理系统{说说}")
@RequestMapping("/admin")
@RestController
public class TalkController {

    @Autowired
    private TalkService talkService;



    @SystemLog(notes = "获取说说列表{后台管理系统}")
    @ApiOperation(value = "获取说说列表接口",notes = "根据条件获取相关说说列表")
    @GetMapping("/talks")
    public ResponseResult talks(@RequestParam("current") Integer current,
                                @RequestParam("size") Integer size,
                                @RequestParam(value = "status",required = false) Integer status)
    {
        return talkService.getTalks(current,size,status);
    }


    @SystemLog(notes = "获取说说详情{后台管理系统}")
    @ApiOperation(value = "获取说说详情接口",notes = "根据说说ID 获取说说详细信息")
    @GetMapping("/talks/{talkId}")
    public ResponseResult getTalkDetail(@PathVariable("talkId") Integer talkId){
        return talkService.getTalkDetailAdminById(talkId);
    }


    @SystemLog(notes = "添加或修改说说{后台管理系统}")
    @ApiOperation(value = "添加或修改说说接口")
    @PostMapping("/talks")
    public ResponseResult addTalk(@RequestBody TalkVo talkVo){
        return talkService.addTalk(talkVo);
    }


    @SystemLog(notes = "删除说说")
    @ApiOperation(value = "删除说说接口")
    @DeleteMapping("/talks")
    public ResponseResult delTalks(@RequestBody Integer[] talkIds){
        return talkService.delTalks(talkIds);
    }

}
